<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>{$words.title} - 主人：{$words.author}</title>

    <link href="__PUBLIC__/static/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="__PUBLIC__/static/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/static/css/animate.min.css" rel="stylesheet">
    <include file="Public/commoncss" />
    <link rel="stylesheet" href="__PUBLIC__/markdown/css/editormd.css" />
    <!-- Sweet Alert -->
    <link href="__PUBLIC__/static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content  animated bounceInLeft article">
    <div class="row">
        <div class="col-lg-10 col-lg-offset-1">
            <div class="ibox">
                <div class="ibox-content">
                    <div class="pull-right">
                        <button class="btn btn-info btn-xs share" type="button" wid="{$words.wid}"><i class="fa fa-share"></i>分享</button>
                        <button class="btn btn-info btn-xs" type="button">主人：{$words.author}</button>
                        <button class="btn btn-info btn-xs" type="button">{$words.source|getWordSource}</button>
                        <button class="btn btn-success btn-xs" type="button" onclick="window.location.href='{:U('Words/index')}'">返回列表</button>
                    </div>
                    <div class="text-center article-title">
                        <h1>
                           {$words.title}
                        </h1>
                        <small>最后笔记时间 ：{$words.time|beenTime}</small>
                    </div>
                    <div id="wordsView">
                        <textarea style="display:none;" name="editormd-markdown-doc">{$words.content}</textarea>
                    </div>
                    <hr>

                    <div class="row">
                        <div class="col-lg-12">
                            <notempty name="prev">
                                <div class="pull-left">
                                    <a href="{:U('view')}?wid={$prev['wid']}" class="btn "><i class="fa fa-angle-double-left"></i> {$prev.title}</a>
                                </div>
                            </notempty>
                            <notempty name="next">
                                <div class="pull-right">
                                    <a href="{:U('view')}?wid={$next['wid']}" class="btn "> {$next.title} <i class="fa fa-angle-double-right"></i></a>
                                </div>
                            </notempty>
                        </div>
                    </div>


                </div>
            </div>
        </div>
    </div>

</div>
<include file="Public/commonjs" />
<script src="__PUBLIC__/static/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__PUBLIC__/static/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/markdown/lib/marked.min.js"></script>
<script src="__PUBLIC__/markdown/lib/prettify.min.js"></script>
<script src="__PUBLIC__/markdown/lib/raphael.min.js"></script>
<script src="__PUBLIC__/markdown/lib/underscore.min.js"></script>
<script src="__PUBLIC__/markdown/lib/sequence-diagram.min.js"></script>
<script src="__PUBLIC__/markdown/lib/flowchart.min.js"></script>
<script src="__PUBLIC__/markdown/lib/jquery.flowchart.min.js"></script>
<script src="__PUBLIC__/markdown/editormd.js"></script>
<script src="__PUBLIC__/static/js/plugins/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        var wordsView;
        wordsView = editormd.markdownToHTML("wordsView", {
            htmlDecode      : "style,script,iframe",  // you can filter tags decode
            emoji           : true,
            taskList        : true,
            tex             : true,  // 默认不解析
            flowChart       : true,  // 默认不解析
            sequenceDiagram : true,  // 默认不解析
        });

        $(".share").click(function(){
            var wid = $(this).attr('wid');
            swal({
                title: "要把笔记分享给其他人？",
                type: "input",
                showCancelButton: true,
                closeOnConfirm: false,
                confirmButtonColor: "#DD6B55",
                cancelButtonText:"取消",
                confirmButtonText: "确定",
                animation: "slide-from-top",
                inputPlaceholder: "这里输入6位pin码,留空则是默认共享！",
            },function(inputValue){
                if (inputValue === false) return false;
                if (inputValue.length !== 6 && inputValue > 0 ){
                    swal("PIN码必须为6位");
                    return false;
                }else{
                    $.post("{:U('Com/share')}?stu=word",{wid:wid,pin:inputValue},function(data){
                        if(data.status !=='y' ){
                            swal("参数错误", data.info,"warning");
                        }else{
                            if(inputValue==''){
                                swal("已成功分享","链接："+data.path, "success");
                            }else{
                                swal("已成功分享", "PIN码: " + inputValue+" 链接："+data.path, "success");
                            }
                        }
                    });
                }
            });
        })

    })
</script>
</body>
</html>